<?php

class CComponent
{
    // event
    private $_e;
    // method
    private $_m;

    public function __get($name)
    {
        $getter = 'get'. $name;
        if(method_exists($this, $getter))
            return $this->$getter();
        else if(strncasecmp($name, 'on', 2) && method_exists($this, $name))
        {
            $name = strtolower($name);
            if(!isset($this->_e[$name]))
                $this->_e[$name] = '$name';
            return $this->_e[$name];
        }
        else if(isset($this->_m[$name]))
            return $this->_m[$name];
    }

    public function __set($name, $value)
    {
        $setter = 'set'. $name;
        if(method_exists($this, $setter))
            return $this->$setter($value);
    }

    public function __isset($name)
    {
        $getter = 'get'. $name;
        if(method_exists($this, $getter))
            return $this->$getter() !== null;
    }

    public function __unset($name)
    {
        $setter = 'set'. $name;
        if(method_exists($this, $setter))
            $this->$setter(null);
    }

    public function __call($name, $parameters)
    {
        return $this->_m;
    }
}
